<template>
  <van-cell center title="心动模式">
    <template #right-icon>
      <van-switch v-model="mode" @click="getUserList"/>
    </template>
  </van-cell>
  <UserCardList :user-list="userList"/>
  <van-empty
      v-if="userList.length < 1 || userList === []"
      description="未匹配到用户"/>
</template>

<script setup lang="ts">
import {onMounted} from "vue";
import {ref} from 'vue'
import {matchUsers, RecommendUsers} from "../../services/api.ts";
import UserCardList from '../../components/UserCardList/index.vue'

const userList: API.User[] = ref([])
const mode = ref(false)

const getUserList =async () => {
  if (mode.value == true) {
    //心动模式
    const res = await matchUsers({
      params: {
        num: 10,
      }
    })
    if (res.code === 0) {
      userList.value = res?.data
    }
  }else {
    //普通模式
    const res = await RecommendUsers({
      params: {
        current: 0,
        pageSize: 10,
      }
    })
    // console.log(res.data.records)
    if (res.code === 0) {
      userList.value = res.data.records
    }
  }

}

onMounted(async () => {
  await getUserList()
})

</script>

<style scoped>

</style>